You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
768 B
21 lines
768 B
import { defineWrappedResponseHandler } from "#server/utils/handler";
|
|
import { R } from "#server/utils/response";
|
|
import { resolveAgentIdentity } from "#server/service/agent/identity";
|
|
import { getSessionByIdAndUser, getMessagesBySession } from "#server/service/agent/session";
|
|
|
|
export default defineWrappedResponseHandler(async (event) => {
|
|
const identity = await resolveAgentIdentity(event);
|
|
const id = getRouterParam(event, "id");
|
|
if (!id) {
|
|
return R.error("参数无效", null);
|
|
}
|
|
|
|
const session = await getSessionByIdAndUser(id, identity.userId, identity.tempToken);
|
|
if (!session) {
|
|
return R.error("会话不存在", null);
|
|
}
|
|
|
|
const messages = await getMessagesBySession(id, { limit: 50 });
|
|
|
|
return R.success({ session, messages });
|
|
});
|
|
|